package com.flash.BusinessParameters.service.impl;

import com.flash.BusinessParameters.entity.Broker;
import com.flash.BusinessParameters.entity.BrokerDealSeat;
import com.flash.BusinessParameters.entity.DealSeat;
import com.flash.BusinessParameters.mapper.DealSeatMapper;
import com.flash.BusinessParameters.service.DealSeatService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class DealSeatServiceImpl implements DealSeatService {

    @Resource
    DealSeatMapper dealSeatMapper;


    public String buildWhere(String seatName){
        StringBuffer strWhere=new StringBuffer();
        if(seatName!=null && !seatName.equals("")){
            strWhere.append(" and seatName like '%" + seatName + "%'" );
        }
        return strWhere.toString();
    }
    @Override
    public List<BrokerDealSeat> selectDealSeatMap(String seatName,int page, int limit) {
        HashMap map = new HashMap();
        System.out.println("DealSeatServiceImpl====selectDealSeatMap====strWhere" + buildWhere(seatName) );
        map.put("strWhere",buildWhere(seatName));
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        return dealSeatMapper.selectDealSeatMap(map);
    }

    @Override
    public int selectCountDealSeat() {
        return dealSeatMapper.selectCountDealSeat();
    }

    @Override
    public List<DealSeat> selectDealSeat() {
        return dealSeatMapper.selectDealSeat();
    }

    @Override
    public int insertBroker(Broker broker) {
        return dealSeatMapper.insertBroker(broker);
    }

    @Override
    public int insertDealSeat(DealSeat dealSeat) {
        return dealSeatMapper.insertDealSeat(dealSeat);
    }

    @Override
    public int updateDealSeat(DealSeat dealSeat) {
        return dealSeatMapper.updateDealSeat(dealSeat);
    }

    @Override
    public int updateBroker(Broker broker) {
        return dealSeatMapper.updateBroker(broker);
    }

    @Override
    public int deleteDealSeat(String seatId) {
        return dealSeatMapper.deleteDealSeat(seatId);
    }


}
